/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package csp;

import java.util.Set;

/**
 *
 * @author Leandro
 */
public class MVR implements HeuristicaVariable {

    public Variable getNextVariable(CSP problema) {

        int valoresRestantes=-1;
        Variable nextVariable=null;
        for(Variable v:problema.getVariables()){
            if(v.getValoresPosibles().size() > valoresRestantes){
                valoresRestantes=v.getValoresPosibles().size();
                nextVariable=v;
            }
        }
        if(nextVariable!=null && valoresRestantes!= -1){
            problema.setVariablePorAsignar(problema.getVariables().indexOf(nextVariable));
            return nextVariable;
        }else{
        return null;
        }
    }

}
